{% extends "adibilisadminBundle::layout.html.twig" %}
     
{% block title %}
    Liste des activités - {{ parent() }}
{% endblock %}

{% block adibilisadmin_body %}

{% if app.session.hasFlash('info') %}
    <div class="alert alert-success">
        {{ app.session.flash('info') }}
    </div>
{% endif %}


<!-- Start welcome-message -->           
<section class="welcome-message">
    <div class="container">
        <div class="hero-unit">
             <h4>{{ 'activite.index.title'|trans }} <br> <small>{{ 'activite.index.subtitle'|trans }}</small></h4>

        </div>
    </div>
</section>
<!-- End welcome-message -->

<!--  <h1>{{ 'activite.index.title'|trans }}</h1> -->
    <hr />


<table width="100%"  id="table_id" class="table ">
    <thead>
        <tr>
            <th >{{ 'activite.index.photo'|trans }}</th>
            <!-- <th width="10%">Référence</th> -->
            <th>{{ 'activite.index.name'|trans }}</th>
            <th>{{ 'activite.index.category'|trans }}</th>
            {% if is_granted('ROLE_ADMIN') %}
            <th width="12%">{{ 'activite.index.actions'|trans }}</th>
            {% endif %}
        </tr>
    </thead>
    <tbody>

        {% for activite in activites %}

        {% if activite.image %}
            {% set path = "/uploads/img/" ~ activite.image.id ~ '.' ~ activite.image.url %}
        {% else %}
        
            {% set path = "/img/defaultactivity.png" %}
        {% endif %}

        <tr>
            <td height="100px" style="background-image:url('{{ path | apply_filter('activites_thumb') }} '); background-size: cover; background-position: center center;"></td>
            <!-- <td><a href="{{ path('adibilisadmin_voir', { 'id': activite.id }) }}">{{ activite.reference }}</a></td> -->
            <td>
                <a href="{{ path('adibilisadmin_voir', { 'id': activite.id }) }}"> <b>{{ activite.name }}</b> 
                </a>
                </br>   
                {{ activite.address }} - 
                {{ activite.locality.npa }}
                {{ activite.locality.locality }} </br>

                {{ activite.telephone }} </br>
                {{ activite.email }}
            </td>
            <td>

            {% if app.request.locale == 'fr' %}
                {% for category in activite.categories %}
                    {{ category.name }}  </br>
                {% endfor %}
            {% endif %}

            {% if app.request.locale == 'en' %}
                {% for category in activite.categories %}
                    {{ category.nameen }}  </br>
                {% endfor %}
            {% endif %}

            {% if app.request.locale == 'de' %}
                {% for category in activite.categories %}
                    {{ category.namede }}  </br>
                {% endfor %}
            {% endif %}

            </td>
            {% if is_granted('ROLE_ADMIN') %}
            <td>
                <a href="{{ path('adibilisadmin_voir', { 'id': activite.id }) }}" class="btn-small">
                    <i class="icon-info-sign"></i>
                    {{ 'activite.index.details'|trans }}
                  </a>
                
                  </br>

                <a href="{{ path('adibilisadmin_supprimer', { 'id': activite.id }) }}" class="btn-small">
                        <i class="icon-trash"></i>
                        {{ 'activite.index.delete'|trans }}
                      </a>
                      </br>

                <a href="{{ path('adibilisadmin_modifier', { 'id': activite.id }) }}" class="btn-small">
                    <i class="icon-edit"></i>
                    {{ 'activite.index.modify'|trans }}
                </a>
                
            
            </td>
            {% endif %}
        </tr>
        {% endfor %}

    </tbody>
    <tfoot>
        <tr>
            <th> </br>{{ 'activite.index.datatables.search'|trans }} </th>
            <th>{{ 'activite.index.datatables.name_placeholder'|trans }}</th>
            <th>{{ 'activite.index.datatables.category_placeholder'|trans }}</th>
            {% if is_granted('ROLE_ADMIN') %}
            <th></th>
            {% endif %}
        </tr>
    </tfoot>
</table>

{% if is_granted('ROLE_ADMIN') %}
</br>
</br>
<a href="{{ path('adibilisadmin_ajouter') }}" class="btn">
      <i class="icon-plus"></i>
      {{ 'activite.index.add'|trans }}
    </a>
{% endif %}



<script>
var cat = new Array();
var loca = new Array();
{% if app.request.locale == 'fr' %}
    var i =0;
    
    {% for category in categories %}

    cat[i] = "{{category.name}}" ;
    i=i+1;


    {% endfor %}
{% endif %}



{% if app.request.locale == 'en' %}
    var i =0;

    {% for category in categories %}

    cat[i] = "{{category.nameen}}" ;
    i=i+1;


    {% endfor %}
{% endif %}



{% if app.request.locale == 'de' %}
    var i =0;

    {% for category in categories %}

    cat[i] = "{{category.namede}}" ;
    i=i+1;


    {% endfor %}
{% endif %}


i =0;

{% for locality in localities %}

loca[i] = "{{locality.locality}}" ;
i=i+1;


{% endfor %}







</script>

<script>

window.onload = loadTable;

function loadTable()
    {
                 $('#table_id').dataTable(

                      {
                        "iDisplayLength": 5,
                        "aLengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "{{ 'activite.index.datatables.all'|trans }}"]],
                        


                          "oLanguage": {
                            "sLengthMenu": "{{ 'activite.index.datatables.bypage'|trans }}  _MENU_ ",
                            "sZeroRecords": "{{ 'activite.index.datatables.noresult'|trans }}",
                            "sInfo": " {{ 'activite.index.datatables.number'|trans }}",
                            "sInfoEmpty": "{{ 'activite.index.datatables.records'|trans }}",
                            "sSearch": "{{ 'activite.index.datatables.search_global'|trans }}",
                            "sNext": "{{ 'activite.index.datatables.next'|trans }}",
                            "sInfoFiltered": "{{ 'activite.index.datatables.filter'|trans }}",
                            "oPaginate": {
                                  "sFirst":      "{{ 'activite.index.datatables.first'|trans }}",
                                  "sPrevious":   "{{ 'activite.index.datatables.previous'|trans }}",
                                  "sNext":       "{{ 'activite.index.datatables.next'|trans }}",
                                  "sLast":       "{{ 'activite.index.datatables.last'|trans }}"
                              },
                          }
                        }

                  ).columnFilter(
               {
                     aoColumns: [
                                    null,
                                    {
                                         type: "select",
                                         values: loca
                                    },
                                    {
                                         type: "select",
                                         values: cat
                                    },
                                    null,
  
                                 ]
               }
 );

              }


</script>




{% endblock %}